import request from '@/request'
const URL = process.env.VUE_APP_API

// 列表
export function getList(params) {
  return request({
    url: `${URL}/manage/upmsDataPermission/list`,
    method: 'get',
    params
  })
}

// 科室管理
export function getListTreeOrg(params) {
  return request({
    url: `${URL}/manage/upms/org/tree`,
    method: 'get',
    params
  })
  // return new Promise(resolve => {
  //   setTimeout(() => {
  //     resolve({
  //       data: [
  //         {
  //           children: [
  //             {
  //               gmtCreate: "2021-05-18T06:34:10.221Z",
  //               id: "123",
  //               isLocked: 0,
  //               orgName: "string",
  //               address: "asd2"
  //             }
  //           ],
  //           gmtCreate: "2021-05-18T06:34:10.221Z",
  //           id: "string",
  //           isLocked: 0,
  //           orgName: "string",
  //           address: "asd"
  //         }
  //       ]
  //     });
  //   }, 1000);
  // });
}

// 获取角色数据
export function getRoleList(data) {
  return request({
    url: `${URL}/manage/upms/role/search`,
    method: 'post',
    data
  })
}

// 关联用户
export function getUserList(params) {
  return request({
    url: `${URL}/manage/upmsDataPermission/userList`,
    method: 'get',
    params
  })
}

// 新增-编辑
export function addAndEidt(data) {
  return request({
    url: `${URL}/manage/upmsDataPermission/edit`,
    method: 'post',
    data
  })
}

// 查看
export function addAndEidtInfo(params) {
  return request({
    url: `${URL}/manage/upmsDataPermission/detail/${params.roleId}`,
    method: 'get'
  })
}

// 禁用
export function upmsDataPermissionLock(params) {
  return request({
    url: `${URL}/manage/upmsDataPermission/disable`,
    method: 'post',
    params
  })
}

// 删除
export function upmsDataPermissionDelete(params) {
  return request({
    url: `${URL}/manage/upmsDataPermission/delete`,
    method: 'get',
    params
  })
}

export function upmsDataPermissionForAdd(params) {
  // params;
  return request({
    url: `${URL}/manage/visitPlanType/list?limit=10000&pager=1`,
    method: 'get'
  })
}
